<template>
  <div class="cartBox">
    <div class="cart-header">
      <div class="gback" @click="backHome()">
        <van-icon name="arrow-left" size="20px" />
      </div>
      <h3 class="cart-tit">我的购物车</h3>
      <div class="cart-search" @click="gbackSearch()">
        <van-icon name="search" size="20px" />``
      </div>
    </div>

    <div class="cart-nav">
      <ul>
        <li
          :class="currentIndex == index ? 'active' : ''"
          @click="Tabs(index)"
          v-for="(item, index) in titles"
          :key="index"
        >
          {{ item }}
        </li>
      </ul>
    </div>
    <keep-alive>
      <component :is="inital"></component>
    </keep-alive>
  </div>
</template>
<script>
import All from "./components/All.vue";
import Payment from "./components/Payment.vue";
import Share from "./components/Share.vue";
import Deliver from "./components/Deliver.vue";
import Harvest from "./components/Harvest.vue";
import Evaluate from "./components/Evaluate.vue";

export default {
  name: "Cart",
  data() {
    return {
      inital: "All",
      currentIndex: 0,
      titles: ["全部", "待付款", "待分享", "待发货", "待收货", "带评论"],
      arrs: ["All", "Payment", "Share", "Deliver", "Harvest", "Evaluate"],
    };
  },
  components: {
    All,
    Payment,
    Share,
    Deliver,
    Harvest,
    Evaluate,
  },
  methods: {
    Tabs(index) {
      this.inital = this.arrs[index];
      this.currentIndex = index;
    },
    backHome() {
      location.href = "./index.html";
    },
    gbackSearch() {
      location.href = "./search.html";
    },
  },
};
</script>
<style scoped>
.cartBox {
  width: 100%;
  overflow: hidden;
  position: relative;
}
.cart-header {
  width: 100%;
  height: 49px;
  border: 1px solid #ddd;
  box-sizing: border-box;
  padding: 0 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.gback,
.cart-search {
  color: #9c9c9c;
}
.cart-tit {
  font-size: 15px;
  color: #333;
  font-weight: normal;
}
.cart-nav {
  width: 100%;
  height: 43px;
  position: relative;
  background: #fff;
}
.cart-nav ul {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-around;
  border-bottom: 1px solid #ededed;
}
.cart-nav ul li {
  font-size: 15px;
  color: #151516;
  position: relative;
}
.cart-nav ul li.active {
  color: #e02e24 !important ;
}
.cart-nav ul li.active::after {
  content: "";
  width: 100%;
  height: 2px;
  background: #e02e24;
  position: absolute;
  bottom: -12px;
  left: 0;
}
</style>